package com.mz.demo.utils.entity;

import com.mz.demo.entity.SysUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
public class LoginUser implements UserDetails {

    private SysUser sysUser;
    private List<String> permissions;

    public  LoginUser( SysUser user, List<String> permissions ){
        this.sysUser = user;
        this.permissions = permissions;
    }

    public  LoginUser( SysUser user){
        this.sysUser = user;
    }

    //返回权限集合
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    //返回用户密码
    @Override
    public String getPassword() {
        return this.sysUser.getPassword();
    }

    //返回用户的帐号
    @Override
    public String getUsername() {
        return this.sysUser.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
